function Km2 = lpcvd_Km2(L,mode,method)
Km2 = zeros(mode,mode);
d_phi = zeros(L,L);
dx = pi/L;
% dx = 1.0;
if nargin == 2
    method = 'ana';
end
if strcmp(method,'dis')
    for m = 1:mode
        for n = 1:mode
            for ix = 1:L
                for iy = 1:L
                    d_phi(ix,iy) = exp(2*1i*((m-1)*ix+(n-1)*(iy-1))*dx)-exp(1i*2*((m-1)*(ix-1)+(n-1)*(iy-1))*dx);
                end
            end
            Km2(m,n) = sum(sum(d_phi.*conj(d_phi)))/(pi^2*L^2*dx^2);
        end
    end
elseif strcmp(method,'ana')
    for m =1:mode
        for n = 1:mode
            Km2(m,n) = (2-2*cos(2*(m-1)*dx))/(dx^2*pi^2);
        end
    end
else
    error('Invalid method');
end